<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

class DemandOrder extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // Create
    public function sceneCreate(): DemandOrder
    {
        return $this
            ->append('data.demand_order', 'require')
            ->append('data.demand_order.project_id', 'require|integer')
            ->append('data.demand_order.demand_type', 'require|in:demand_order,review_feedback')
            ->append('data.demand_order.title', 'require|regex:/^[\x{4e00}-\x{9fa5}a-zA-Z\(\)（、）\-_\d]{1,24}$/u')
            ->append('data.demand_order.episode_codes', 'require')
            ->append('data.demand_order.module_code', 'require')
            ->append('data.demand_order.step_category_ids', 'array')
            ->append('data.demand_order.entry_limit_time', 'integer')
            ->append('data.demand_order.permissions', 'in:on,off,one,two');
    }

    // Update
    public function sceneUpdate()
    {
        return $this
            ->append('data.demand_order.id', 'require')
            ->append('data.demand_order.title', 'regex:/^[\x{4e00}-\x{9fa5}a-zA-Z\(\)（、）\-_\d]{1,24}$/u')
            ->append('data.demand_order.step_category_ids', 'array')
            ->append('data.demand_order.entry_limit_time', 'integer')
            ->append('data.demand_order.permissions', 'in:on,off,one,two');
    }

    // GetDemandOrderList
    public function sceneGetDemandOrderList(): DemandOrder
    {
        return $this
//            ->append('param.filter.project_id|项目ID', 'require')
            ->append('param.filter.demand_type|需求单类型', 'require|in:demand_order,review_feedback');
    }

    // GetDemandOrderList
    public function sceneGetDemandOrderListWithProjectRequired(): DemandOrder
    {
        return $this
            ->append('param.filter.project_id|项目ID', 'require')
            ->append('param.filter.demand_type|需求单类型', 'require|in:demand_order,review_feedback');
    }

    // DeleteDemandOrder
    public function sceneDeleteDemandOrder(): DemandOrder
    {
        return $this
            ->append('param.filter.project_id|项目ID', 'require|integer')
            ->append('param.filter.id', 'require');
    }

    // Import
    public function sceneImport()
    {
        return $this->append('data.list|需求列表', 'require|array')
            ->append('data.module_code|模块CODE', 'require|in:shot,asset')
            ->append('data.project_id|项目ID', 'require|integer');
    }

    // ImportBaseInfo
    public function sceneImportBaseInfo()
    {
        return $this->append('initial_episode_code|集数', 'require')
            ->append('showings_number|场次', 'require')
            ->append('name|资产/镜头名称', 'require')
            ->append('director_star|导演关注', 'in:是,否')
            ->append('key_shot|关键镜头', 'in:是,否')
            ->append('enable|启用\废除', 'in:启用,废除')
            ->append('is_append|是否属于新增', 'in:是,否');
    }

    // ImportDemand
    public function sceneImportDemand()
    {
        return $this->append('reason_type|返修类型', 'require')
            ->append('text|需求内容', 'require')
            ->append('demand_status|需求状态', 'in:已拒绝,已接受,待确认');
    }

    // Publish
    public function scenePublish()
    {
        return $this->append('param.entity_id_list|要发布的任务', 'require|array')
            ->append('param.review_feedback_id|需求单ID', 'require|integer')
            ->append('param.module_code|需求单模块CODE', 'require|in:asset,shot');
    }

    // BatchUpdateSameNote
    public function sceneBatchUpdateSameNote()
    {
        return $this->append('data.id|需求ID', 'require|array')
            ->append('data.accept_changes', 'require');
    }

    // BatchRemoveUnpublishedEntity
    public function sceneBatchRemoveUnpublishedEntity()
    {
        return $this->append('data.id', 'require|array');
    }

    // SaveNoteDownstreamRepairStatus 验证场景定义
    public function sceneSaveNoteDownstreamRepairStatus()
    {
        return $this->append("param.note_entity_relation_id", "require|integer")
            ->append("param.repair_accept_status", "require|in:yes,no");
    }
	// 需求单统计 验证场景定义
	public function sceneGetDemandOrderListStatistics()
	{
		return $this->append('param', 'array');
	}

    // 获取需求单id 验证场景定义
    public function sceneFindDemandOrderIds()
    {
        return $this->append("entity_id", "require|array");
    }

    // 需求单内容验证自定义
    public function sceneFindReviewFeedbackContent()
    {
        return $this->append("data.review_feedback_id", "require|array")
            ->append("data.step_category_id", "require")
            ->append("data.entity_id", "require")
            ->append("data.project_id", "require");
    }

    // 验证场景自定义 需求单信息
    public function sceneGetReviewFeedBackList()
    {
        return $this->append("review_feedback_id","require|array")
        ->append("entity_id","require")
        ->append("step_category_id","require");
    }

    //需求单的发布时间 验证场景
    public function sceneGetReviewFeedbackPublished()
    {
       return $this->append("review_feedback_id","require|array")
           ->append("step_category_id","require");
    }

    // 需求单的原计划时间,和新的计划时间 验证场景
    public function sceneGetOriginalNewPublished()
    {
        return $this->append("review_feedback_id","require|array")
            ->append("task_id","require");
    }

    public function sceneCloseDemandOrder()
    {
        return $this->append('param.review_feedback_id|需求单ID', 'require|integer');
    }
}
